package com.xiao.hao.exception;

import cn.hutool.core.util.ObjectUtil;
import lombok.Builder;
import lombok.Getter;

/**
 * @Desciption:
 * @Author: 郑焱军
 * @Date: 2022/9/21 20:30
 */
@Builder
@Getter
public class AuthException extends RuntimeException {


    private final String message;

    public AuthException(String message) {
        this.message = message;
    }


    public static void isTrue(boolean expression, String message) {
        if (!expression) {
            throw AuthException.builder().message(message).build();
        }
    }


    public static void notTrue(boolean expression, String message) {
        isTrue(!expression, message);
    }


    public static void isNull(Object object, String message) {
        isTrue(ObjectUtil.isNull(object), message);
    }


    public static void notNull(Object object, String message) {
        isTrue(ObjectUtil.isNotNull(object), message);
    }


}